<html>
<head><meta charset="utf-8"><title>Including `source` in error messages · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html">Including `source` in error messages</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210780148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780148">(Sep 21 2020 at 18:19)</a>:</h4>
<p><a href="https://dev.to/e_net4/migrating-from-quick-error-to-snafu-a-story-on-revamped-error-handling-in-rust-58h9">Migrating from quick-error to SNAFU: a story on revamped error handling in Rust</a> mentions that deciding whether or not to have something equivalent to <code>caused by: {source}</code> in an error message is a tough decision.</p>



<a name="210780164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780164">(Sep 21 2020 at 18:19)</a>:</h4>
<p>I think it'd be nice if the group could help with that.</p>



<a name="210780185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780185">(Sep 21 2020 at 18:19)</a>:</h4>
<p>I have opinions on this that I'd be happy to share</p>



<a name="210780260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780260">(Sep 21 2020 at 18:20)</a>:</h4>
<p>I think it boils down to if we think the pattern of having a reporting type and an error type where the reporting type handles the format and the error type handles the content is the best way to go</p>



<a name="210780292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780292">(Sep 21 2020 at 18:20)</a>:</h4>
<p>I think it is though there really are those pesky issues around failing to convert errors to reporters before printing them and losing context as a result</p>



<a name="210780300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780300">(Sep 21 2020 at 18:20)</a>:</h4>
<p>which _really_ sucks</p>



<a name="210780313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780313">(Sep 21 2020 at 18:20)</a>:</h4>
<p>SNAFU tends to encourage doing it because it makes the simpler case have more data. But it also gets in the way of the prettier outputs.</p>



<a name="210780326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780326">(Sep 21 2020 at 18:20)</a>:</h4>
<p>yea</p>



<a name="210780363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780363">(Sep 21 2020 at 18:21)</a>:</h4>
<p>i think being able to do multi line output on CLIs and oneline outputs for logs is a very desirable property personally</p>



<a name="210780402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780402">(Sep 21 2020 at 18:21)</a>:</h4>
<p>fun wild idea is to add / use the formatting modifiers for Display somehow</p>



<a name="210780425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780425">(Sep 21 2020 at 18:21)</a>:</h4>
<p><code>{}</code> vs <code>{#}</code></p>



<a name="210780428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780428">(Sep 21 2020 at 18:21)</a>:</h4>
<p>that was <span class="user-mention" data-user-id="119235">@David Tolnay</span> 's idea</p>



<a name="210780441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780441">(Sep 21 2020 at 18:21)</a>:</h4>
<p>one second let me link you an old pre rfc of mine</p>



<a name="210780511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780511">(Sep 21 2020 at 18:22)</a>:</h4>
<p><a href="https://paper.dropbox.com/doc/Collaborative-Summary-3-Fact-Finding-Pre-RFCs-around-Error-Handling-Reporting--A8BcfCfWgPL0Szl8rqaqnVCeAQ-dnShKo1SsHtdF4Yheeoco">https://paper.dropbox.com/doc/Collaborative-Summary-3-Fact-Finding-Pre-RFCs-around-Error-Handling-Reporting--A8BcfCfWgPL0Szl8rqaqnVCeAQ-dnShKo1SsHtdF4Yheeoco</a></p>



<a name="210780565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780565">(Sep 21 2020 at 18:22)</a>:</h4>
<p>the idea is either we add an <code>is_termination</code> flag to std::fmt::Formatter (david and your ideas, approximately) or we introduce a 3rd fmt trait (my idea)</p>



<a name="210780620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780620">(Sep 21 2020 at 18:23)</a>:</h4>
<p>but neither one solves the problem completely</p>



<a name="210780635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780635">(Sep 21 2020 at 18:23)</a>:</h4>
<p>well, is_termination comes close actually</p>



<a name="210780647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780647">(Sep 21 2020 at 18:23)</a>:</h4>
<p>well actually no they both work about the same</p>



<a name="210780759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780759">(Sep 21 2020 at 18:24)</a>:</h4>
<p>the problem with both is that you basically end up with competing reporters</p>



<a name="210780801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210780801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210780801">(Sep 21 2020 at 18:24)</a>:</h4>
<p>either you report yourself via <code>is_termination</code> / <code>std::fmt::Report</code> or you get reported via your <code>Display</code> impl and a Reporting type</p>



<a name="210781033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210781033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210781033">(Sep 21 2020 at 18:26)</a>:</h4>
<p>it seems like the only way we could properly fix this is by changing a ton of panic machinery to use specialization to see if the type you're formatting is an <code>Error</code> and if so it would need to convert it to the reporting type, and then you're somehow trying to set the reporting type used by std macros and that doesn't sound good</p>



<a name="210781058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Including%20%60source%60%20in%20error%20messages/near/210781058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Including.20.60source.60.20in.20error.20messages.html#210781058">(Sep 21 2020 at 18:26)</a>:</h4>
<p>_incase it isn't obvious this is all very half baked rn_</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>